#ifndef _NAVIGATIONDATA_H_
#define _NAVIGATIONDATA_H_
#include <stdint.h>

class Position_3D {
public:
	double latitude_d;	  // in degrees
	double longitude_d;  // in degrees
	float  altitude_f;   // in meters
};

class CourseSpeed {
public:
	float course_f;      // in degrees
	float speed_f; 		  // in m/s
};

class NavigationData {
public:
	enum DataStatus {
	  INVALID, NEWDATA, CONSUMED
	};

	uint32_t systemTimestampMillis;
  	uint32_t itod;

	Position_3D position;
	CourseSpeed groundCourseSpeed;

	bool isValid;				// OK (true) or warning (false)
	uint8_t fixMode;	  		// system dependent
	uint8_t numberOfSatellites;

	float horizontalAccuracy_f; // in 0.01m = cm.
	float verticalAccuracy_f;   // in 0.01m = cm.

	bool isSupersededBy(NavigationData* other) {
		if (isValid && !other->isValid) return false;
		if (other->systemTimestampMillis < systemTimestampMillis) return false;
		if (other->position.latitude_d == 0 && other->position.longitude_d == 0) return false;
		// If other's horizontal accuracy is more than 50m worse than this, use this.
		// if (other->horizontalAccuracy_f > horizontalAccuracy_f + 5000) return false;
		return true;
	}
};

void satfixToString(uint8_t satfix, char* buf);

extern NavigationData navigationData;
void onNewNavigationData();

#endif // _NAVIGATIONDATA_H_
